//package com.stellar.core.util;
//
//import org.springframework.beans.BeansException;
//import org.springframework.beans.factory.NoSuchBeanDefinitionException;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.util.Map;
//
//@Component
//public class SpringContextUtils implements ApplicationContextAware {
//
//    private static ApplicationContext applicationContext;
//
//    @Override
//    public void setApplicationContext(ApplicationContext applicationContext)
//            throws BeansException {
//        this.applicationContext = applicationContext;
//    }
//
//    public static ApplicationContext getApplicationContext() {
//        return applicationContext;
//    }
//
//    public static Object getBean(String name) throws BeansException {
//        return applicationContext.getBean(name);
//    }
//
//    public static Object getBean(String name, Class requiredType)
//            throws BeansException {
//        return applicationContext.getBean(name, requiredType);
//    }
//
//    public static Object getBean(Class requiredType)
//            throws BeansException {
//        return applicationContext.getBean(requiredType);
//    }
//
//    public static <T> T getBeanByType(Class<T> clazz){
//        return applicationContext.getBean(clazz);
//    }
//
//    public static boolean containsBean(String name) {
//        return applicationContext.containsBean(name);
//    }
//
//    public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
//        return applicationContext.isSingleton(name);
//    }
//
//    public static Class getType(String name)    throws NoSuchBeanDefinitionException {
//        return applicationContext.getType(name);
//    }
//
//    public static <T> Map<String, T> getBeanOfType(Class<T> clazz)    throws NoSuchBeanDefinitionException {
//        return applicationContext.getBeansOfType(clazz);
//    }
//
//    public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
//        return applicationContext.getAliases(name);
//    }
//
//    public static HttpServletRequest getHttpServletRequest() {
//        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//    }
//
//    public static HttpServletResponse getHttpServletResponse() {
//        return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse();
//    }
//
//    public static HttpSession getHttpSession() {
//        HttpServletRequest request = getHttpServletRequest();
//        return request.getSession();
//    }
//
//}